<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>View comments</title>
</head>
<body>

<c:if test="${ not empty sessionScope.user }">
	<a href="./LogoutController">Log out</a><br/>
</c:if>
<c:if test="${ empty sessionScope.user }">
	<a href="./login.jsp">Log in</a> <br>
	<a href="./register.jsp">Register</a><br/>
</c:if>
<a href="./HomeController">Home</a> <br/>

<h2>Recent comments by other on photos of user: <a href="./ViewUserController?id=${ requestScope.viewedUser.id }">${ requestScope.viewedUser.firstname } ${ requestScope.viewedUser.lastname }</a></h2>

<c:if test="${ empty requestScope.comments }">
	No recent comments
</c:if>

<c:if test="${ not empty requestScope.comments }">
	<table>
		<c:forEach var="currentComment" items="${ requestScope.comments }" varStatus="status">
			<c:if test="${ currentComment.photo.publiclyAvailable }">
				<tr>
					<td>
						<a href="./ViewPhotoController?id=${ currentComment.photo.id }">
							<img alt="Greška, nema slike" src="${ currentComment.photo.thumbnailLocation }">
						</a>
					</td>
					<td>
						<c:out value="${ status.count }."></c:out>
						<a href="./ViewUserController?id=${ currentComment.user.id }">
						<c:out value="${ currentComment.user.firstname } ${ currentComment.user.lastname }"></c:out>
						</a>
						<c:out value=" - ${ currentComment.date }"></c:out>
						<br/>
						<c:out value="${ currentComment.title } - ${ currentComment.contents }"></c:out>
					</td>
				</tr>
			</c:if>
		</c:forEach>
	</table>
</c:if>

</body>
</html>